if($pricelimit>0)
$extracondition = " and r1.price<=$pricelimit ";
$rsql = "(SELECT title,internalUrl,internalUrlNew,imageUrlStr,price,mrp,slug from products where brandId !=15916 and mrp!=0 and price!=0 $extracondition order by $orderby limit " . 40*($page-1) . ",40) union all (SELECT title,internalUrl,internalUrlNew,imageUrlStr,price,mrp,slug FROM products AS r1 JOIN (SELECT (RAND() * (SELECT MAX(Id) FROM products)) AS Idd) AS r2 WHERE r1.Id >= r2.Idd and r1.brandId !=15916 and r1.price!=0 $extracondition ORDER BY r1.Id ASC LIMIT 20)";
//echo $rsql;
//$rsql = 'SELECT title,internalUrl,internalUrlNew,imageUrlStr,price,mrp,slug from products where brandId !=15916 and mrp!=0 and price!=0 $extracondition order by Id desc limit ' . 60*($page-1) . ',60' ;
if(isset($_REQUEST['cid'])){
if(is_numeric($_REQUEST['cid'])){
//if($_REQUEST['type']=='f'){
// $catid = $_REQUEST['cid'];
// $rsql = "SELECT title,internalUrl,imageUrlStr,price,mrp,slug from products inner join (select prodId from categoryAssign where categoryId=$catid OR categoryId in (select categoryId from categories where categoryName like (select concat(categoryName,'>%') from categories where categoryId=$catid)) order by prodId desc limit " . 60*($page-1) . ",60) as c1 on products.Id = c1.prodId";
//}else if($_REQUEST['type']=='a'){
$catid = $_REQUEST['cid'];
//$tresult = $dbf->query("select prodId from categoryAssign where categoryId=$catid OR categoryId in (select categoryId from categories where parentCatId=$catid) order by prodId desc limit " . 60*($page-1) . ",60");
$tresult = $dbf->query("select prodId from categoryAssign where categoryId=$catid order by prodId desc limit " . 60*($page-1) . ",60");
$pids = '';
while($prod=$tresult->fetch_array(MYSQLI_ASSOC)){
$pids .= $prod['prodId'] . ',';
}
unset($tresult);
$pids = substr($pids,0,-1);
if($pids=='')
$pids = 1;
//echo $pids;
if($pricelimit>0)
$extracondition = " and price<=$pricelimit ";
$rsql = "SELECT title,internalUrl,internalUrlNew,imageUrlStr,price,mrp,slug from products where Id in ($pids) $extracondition order by $orderby";
//}
}
}
if(isset($_REQUEST['bid'])){
if(is_numeric($_REQUEST['bid'])){
if($pricelimit>0)
$extracondition = " and price<=$pricelimit ";
$rsql = 'SELECT title,internalUrl,internalUrlNew,imageUrlStr,price,mrp,slug from products where brandId=' . $_REQUEST['bid'] . $extracondition . " order by $orderby limit " . 60*($page-1) . ',60' ;
}
}
$rresult = $dbf->query($rsql);
if($rresult ==false){
//error_log("select prodId from categoryAssign where categoryId=$catid OR categoryId in (select categoryId from categories where parentCatId=$catid) order by prodId desc limit " . 60*($page-1) . ",60");
//error_log($rsql);
}
while($prod=$rresult->fetch_array(MYSQLI_ASSOC)){
//$prod['price'] = ceil($prod['price'] * 0.96);
if($prod['price']==0 || $prod['price']=='' || is_null($prod['price']))
$prod['mrp']=1;
if($prod['mrp']==0 || $prod['mrp']=='' || is_null($prod['mrp']))
$prod['mrp'] = $prod['price'];
$purl = '';
$prod['internalUrl'] = str_replace('~',$prefix,$prod['internalUrlNew']);
$purl = $prod['internalUrl'];
?>